<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>documentName</title>
    <link rel="stylesheet" href="" />
    <style>
      .fix {
        position: fixed;
        right: 40px;
        bottom: 40px;
        display: flex;
        justify-content: center;
        align-items: center;
        width: 120px;
        height: 40px;
        color: #fff;
        background: lightsalmon;
        border-radius: 10px;
        cursor: pointer;
      }

      .content {
        height: 3000px;
      }
    </style>
  </head>
  <body>
    <div class="fix" title="点击后回到顶部">回到顶部</div>
    <div class="content">
      Lorem ipsum dolor, sit amet consectetur adipisicing elit. Tempore excepturi quam ipsa
      repudiandae, porro labore. Veritatis, inventore veniam aliquid, ut necessitatibus omnis
      obcaecati sequi dolore, earum dicta aperiam ullam labore.
    </div>

    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
    <script>
      $(function () {
        $('.fix').on('click', function () {
          $('html, body').animate({ scrollTop: 0, speed: 1500 })
        })
      })
    </script>
  </body>
</html>
